package com.example.hibernate.program;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;

public class Driver {

	public static void main(String[] args) {
		SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
		Session session = sessionFactory.openSession();
		Transaction transaction = session.beginTransaction();
		try {
			LoginName loginName = new LoginName();
			loginName.setFirstName("Emre");
			loginName.setLastName("ÇELEBİ");
			{
				Employee employee = new Employee();
				employee.setLoginName(loginName);
				employee.setHireDate(new Date());
				session.save(employee);
			}			
			transaction.commit();
		} catch (Exception e) {
			transaction.rollback();
		}		
		session.close();
		sessionFactory.close();
	}
}
